import {createRouter, createWebHashHistory} from 'vue-router'
import {routes} from './routes'


const router = createRouter({
	history: createWebHashHistory(),
	routes,
})

router.beforeEach(async (to, from, next) => {
	let token = localStorage.getItem('token')

	if (!token && to.name !== 'login') {
		next({path: '/login'})
		return
	}
	next()
})

export default router
